package com.fitns.user.mapper.baseConfig;

import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.fitns.user.model.baseConfig.TbSysCodeCate;

import java.util.List;
import javax.annotation.Generated;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

@Mapper
public interface TbSysCodeCateMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<TbSysCodeCate> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TbSysCodeCateResult")
    TbSysCodeCate selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TbSysCodeCateResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="cate_name", property="cateName", jdbcType=JdbcType.VARCHAR),
        @Result(column="cate_code", property="cateCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.BIGINT),
        @Result(column="orderlist", property="orderlist", jdbcType=JdbcType.INTEGER),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="create_id", property="createId", jdbcType=JdbcType.BIGINT),
        @Result(column="input_time", property="inputTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modify_id", property="modifyId", jdbcType=JdbcType.BIGINT),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<TbSysCodeCate> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(TbSysCodeCateDynamicSqlSupport.tbSysCodeCate);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, TbSysCodeCateDynamicSqlSupport.tbSysCodeCate);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, TbSysCodeCateDynamicSqlSupport.tbSysCodeCate)
                .where(TbSysCodeCateDynamicSqlSupport.id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(TbSysCodeCate record) {
        return insert(SqlBuilder.insert(record)
                .into(TbSysCodeCateDynamicSqlSupport.tbSysCodeCate)
                .map(TbSysCodeCateDynamicSqlSupport.cateName).toProperty("cateName")
                .map(TbSysCodeCateDynamicSqlSupport.cateCode).toProperty("cateCode")
                .map(TbSysCodeCateDynamicSqlSupport.parentId).toProperty("parentId")
                .map(TbSysCodeCateDynamicSqlSupport.orderlist).toProperty("orderlist")
                .map(TbSysCodeCateDynamicSqlSupport.type).toProperty("type")
                .map(TbSysCodeCateDynamicSqlSupport.createId).toProperty("createId")
                .map(TbSysCodeCateDynamicSqlSupport.inputTime).toProperty("inputTime")
                .map(TbSysCodeCateDynamicSqlSupport.modifyId).toProperty("modifyId")
                .map(TbSysCodeCateDynamicSqlSupport.modifyTime).toProperty("modifyTime")
                .map(TbSysCodeCateDynamicSqlSupport.remark).toProperty("remark")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(TbSysCodeCate record) {
        return insert(SqlBuilder.insert(record)
                .into(TbSysCodeCateDynamicSqlSupport.tbSysCodeCate)
                .map(TbSysCodeCateDynamicSqlSupport.cateName).toPropertyWhenPresent("cateName", record::getCateName)
                .map(TbSysCodeCateDynamicSqlSupport.cateCode).toPropertyWhenPresent("cateCode", record::getCateCode)
                .map(TbSysCodeCateDynamicSqlSupport.parentId).toPropertyWhenPresent("parentId", record::getParentId)
                .map(TbSysCodeCateDynamicSqlSupport.orderlist).toPropertyWhenPresent("orderlist", record::getOrderlist)
                .map(TbSysCodeCateDynamicSqlSupport.type).toPropertyWhenPresent("type", record::getType)
                .map(TbSysCodeCateDynamicSqlSupport.createId).toPropertyWhenPresent("createId", record::getCreateId)
                .map(TbSysCodeCateDynamicSqlSupport.inputTime).toPropertyWhenPresent("inputTime", record::getInputTime)
                .map(TbSysCodeCateDynamicSqlSupport.modifyId).toPropertyWhenPresent("modifyId", record::getModifyId)
                .map(TbSysCodeCateDynamicSqlSupport.modifyTime).toPropertyWhenPresent("modifyTime", record::getModifyTime)
                .map(TbSysCodeCateDynamicSqlSupport.remark).toPropertyWhenPresent("remark", record::getRemark)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbSysCodeCate>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, TbSysCodeCateDynamicSqlSupport.id, TbSysCodeCateDynamicSqlSupport.cateName, TbSysCodeCateDynamicSqlSupport.cateCode, TbSysCodeCateDynamicSqlSupport.parentId, TbSysCodeCateDynamicSqlSupport.orderlist, TbSysCodeCateDynamicSqlSupport.type, TbSysCodeCateDynamicSqlSupport.createId, TbSysCodeCateDynamicSqlSupport.inputTime, TbSysCodeCateDynamicSqlSupport.modifyId, TbSysCodeCateDynamicSqlSupport.modifyTime, TbSysCodeCateDynamicSqlSupport.remark)
                .from(TbSysCodeCateDynamicSqlSupport.tbSysCodeCate);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbSysCodeCate>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, TbSysCodeCateDynamicSqlSupport.id, TbSysCodeCateDynamicSqlSupport.cateName, TbSysCodeCateDynamicSqlSupport.cateCode, TbSysCodeCateDynamicSqlSupport.parentId, TbSysCodeCateDynamicSqlSupport.orderlist, TbSysCodeCateDynamicSqlSupport.type, TbSysCodeCateDynamicSqlSupport.createId, TbSysCodeCateDynamicSqlSupport.inputTime, TbSysCodeCateDynamicSqlSupport.modifyId, TbSysCodeCateDynamicSqlSupport.modifyTime, TbSysCodeCateDynamicSqlSupport.remark)
                .from(TbSysCodeCateDynamicSqlSupport.tbSysCodeCate);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default TbSysCodeCate selectByPrimaryKey(Long id_) {
        return SelectDSL.selectWithMapper(this::selectOne, TbSysCodeCateDynamicSqlSupport.id, TbSysCodeCateDynamicSqlSupport.cateName, TbSysCodeCateDynamicSqlSupport.cateCode, TbSysCodeCateDynamicSqlSupport.parentId, TbSysCodeCateDynamicSqlSupport.orderlist, TbSysCodeCateDynamicSqlSupport.type, TbSysCodeCateDynamicSqlSupport.createId, TbSysCodeCateDynamicSqlSupport.inputTime, TbSysCodeCateDynamicSqlSupport.modifyId, TbSysCodeCateDynamicSqlSupport.modifyTime, TbSysCodeCateDynamicSqlSupport.remark)
                .from(TbSysCodeCateDynamicSqlSupport.tbSysCodeCate)
                .where(TbSysCodeCateDynamicSqlSupport.id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(TbSysCodeCate record) {
        return UpdateDSL.updateWithMapper(this::update, TbSysCodeCateDynamicSqlSupport.tbSysCodeCate)
                .set(TbSysCodeCateDynamicSqlSupport.cateName).equalTo(record::getCateName)
                .set(TbSysCodeCateDynamicSqlSupport.cateCode).equalTo(record::getCateCode)
                .set(TbSysCodeCateDynamicSqlSupport.parentId).equalTo(record::getParentId)
                .set(TbSysCodeCateDynamicSqlSupport.orderlist).equalTo(record::getOrderlist)
                .set(TbSysCodeCateDynamicSqlSupport.type).equalTo(record::getType)
                .set(TbSysCodeCateDynamicSqlSupport.createId).equalTo(record::getCreateId)
                .set(TbSysCodeCateDynamicSqlSupport.inputTime).equalTo(record::getInputTime)
                .set(TbSysCodeCateDynamicSqlSupport.modifyId).equalTo(record::getModifyId)
                .set(TbSysCodeCateDynamicSqlSupport.modifyTime).equalTo(record::getModifyTime)
                .set(TbSysCodeCateDynamicSqlSupport.remark).equalTo(record::getRemark);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(TbSysCodeCate record) {
        return UpdateDSL.updateWithMapper(this::update, TbSysCodeCateDynamicSqlSupport.tbSysCodeCate)
                .set(TbSysCodeCateDynamicSqlSupport.cateName).equalToWhenPresent(record::getCateName)
                .set(TbSysCodeCateDynamicSqlSupport.cateCode).equalToWhenPresent(record::getCateCode)
                .set(TbSysCodeCateDynamicSqlSupport.parentId).equalToWhenPresent(record::getParentId)
                .set(TbSysCodeCateDynamicSqlSupport.orderlist).equalToWhenPresent(record::getOrderlist)
                .set(TbSysCodeCateDynamicSqlSupport.type).equalToWhenPresent(record::getType)
                .set(TbSysCodeCateDynamicSqlSupport.createId).equalToWhenPresent(record::getCreateId)
                .set(TbSysCodeCateDynamicSqlSupport.inputTime).equalToWhenPresent(record::getInputTime)
                .set(TbSysCodeCateDynamicSqlSupport.modifyId).equalToWhenPresent(record::getModifyId)
                .set(TbSysCodeCateDynamicSqlSupport.modifyTime).equalToWhenPresent(record::getModifyTime)
                .set(TbSysCodeCateDynamicSqlSupport.remark).equalToWhenPresent(record::getRemark);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(TbSysCodeCate record) {
        return UpdateDSL.updateWithMapper(this::update, TbSysCodeCateDynamicSqlSupport.tbSysCodeCate)
                .set(TbSysCodeCateDynamicSqlSupport.cateName).equalTo(record::getCateName)
                .set(TbSysCodeCateDynamicSqlSupport.cateCode).equalTo(record::getCateCode)
                .set(TbSysCodeCateDynamicSqlSupport.parentId).equalTo(record::getParentId)
                .set(TbSysCodeCateDynamicSqlSupport.orderlist).equalTo(record::getOrderlist)
                .set(TbSysCodeCateDynamicSqlSupport.type).equalTo(record::getType)
                .set(TbSysCodeCateDynamicSqlSupport.createId).equalTo(record::getCreateId)
                .set(TbSysCodeCateDynamicSqlSupport.inputTime).equalTo(record::getInputTime)
                .set(TbSysCodeCateDynamicSqlSupport.modifyId).equalTo(record::getModifyId)
                .set(TbSysCodeCateDynamicSqlSupport.modifyTime).equalTo(record::getModifyTime)
                .set(TbSysCodeCateDynamicSqlSupport.remark).equalTo(record::getRemark)
                .where(TbSysCodeCateDynamicSqlSupport.id, isEqualTo(record::getId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(TbSysCodeCate record) {
        return UpdateDSL.updateWithMapper(this::update, TbSysCodeCateDynamicSqlSupport.tbSysCodeCate)
                .set(TbSysCodeCateDynamicSqlSupport.cateName).equalToWhenPresent(record::getCateName)
                .set(TbSysCodeCateDynamicSqlSupport.cateCode).equalToWhenPresent(record::getCateCode)
                .set(TbSysCodeCateDynamicSqlSupport.parentId).equalToWhenPresent(record::getParentId)
                .set(TbSysCodeCateDynamicSqlSupport.orderlist).equalToWhenPresent(record::getOrderlist)
                .set(TbSysCodeCateDynamicSqlSupport.type).equalToWhenPresent(record::getType)
                .set(TbSysCodeCateDynamicSqlSupport.createId).equalToWhenPresent(record::getCreateId)
                .set(TbSysCodeCateDynamicSqlSupport.inputTime).equalToWhenPresent(record::getInputTime)
                .set(TbSysCodeCateDynamicSqlSupport.modifyId).equalToWhenPresent(record::getModifyId)
                .set(TbSysCodeCateDynamicSqlSupport.modifyTime).equalToWhenPresent(record::getModifyTime)
                .set(TbSysCodeCateDynamicSqlSupport.remark).equalToWhenPresent(record::getRemark)
                .where(TbSysCodeCateDynamicSqlSupport.id, isEqualTo(record::getId))
                .build()
                .execute();
    }
}